#ifndef PARAMETRS_H_
#define PARAMETRS_H_

#include "General_definitions.h"

#include "string.h"
#include "printf-stdarg.h"
#include "CfgParams.h"
#include "malloc.h"
#include "ParamSetFuncs.h"
#include "ParamSys.h"
#include "LMX2541.h"
#include "llc\llc.h"
///////////////
unsigned char echo_mode;
/////////////////
#ifdef DEBUGING
#define GROUPS_COUNT 9
#else
#define GROUPS_COUNT 7
#endif//DEBUGING

#define SYS_NODES_CNT				1
#define SYS_INFO_PARAMS_COUNT		11

#define UI_NODES_CNT				3
#define UI_MODE_PARAMS_CNT			1
//#define UI_ASYNC_PARAMS_CNT			5
#define UI_SPI_PARAMS_CNT			2
#define UI_UDEF_PARAMS_CNT			1

#define WL_NODES_CNT				1//3
#define WL_LINK_PARAMS_CNT			11
//#define WL_WIFI_PARAMS_CNT			3
//#define WL_BT_PARAMS_CNT			1

#define NET_NODES_CNT				5
#define NET_NETPR_PARAMS_CNT		3
#define NET_WIFI_PARAMS_CNT			3
#define NET_TCPIP_PARAMS_CNT		5
#define NET_SECURITY_PARAMS_CNT		3
#define NET_NCC_PARAMS_CNT			2
/*#define NET_APP_PARAMS_CNT			2
#define NET_TCP_PARAMS_CNT			3
#define NET_MCAST_PARAMS_CNT		3
#define NET_DL_PARAMS_CNT			1//4
*/
#define STATE_NODES_CNT				3
#define STATE_STS_PARAMS_CNT		7
#define STATE_STAT_PARAMS_CNT		3
#define STATE_SYSSTS_PARAMS_CNT		3

#define OPS_NODES_CNT				2
#define OPS_ID_PARAMS_CNT			3
#define OPS_PWRS_PARAMS_CNT			3

#define MON_NODES_CNT				3
#define MON_ENV_PARAMS_CNT	        2
#define MON_UHF_PARAMS_CNT          10
#define MON_WIFI_PARAMS_CNT         4

#define DBG_NODES_CNT				5+1+1+1
#define DBG_NODES_PARAMS_CNT		1
#define ADV_TEST_PARAMS_CNT			2
#define DBG_D_LINK_PARAMS_CNT		3
#define DBG_RSA_PARAMS_CNT			6
#define DBG_SKY_PARAMS_CNT			2


#define ADV_NODES_CNT				4
#define ADV_NODES_DPORT_CNT			7
#define ADV_NODES_XMOD_CNT			3
#define ADV_NODES_SIM_CNT			3

#define PARAMETER_TYPE_INT			-4
#define PARAMETER_TYPE_SHORT		-2
#define PARAMETER_TYPE_CHAR			-1
#define PARAMETER_TYPE_UCHAR		1
#define PARAMETER_TYPE_UINT			4
#define PARAMETER_TYPE_USHORT		2
#define PARAMETER_TYPE_DOUBLE		5
#define PARAMETER_TYPE_NONE			0

#define MAX_PARAMETER_LEN	5
#define MAX_PARAM_VAL_LEN 16
#define MAX_PARAM_NOD_LEN 6
#define MAX_GRP_LEN 10
#define MAX_PARAM_COUNT 8
#define MAX_PARAM_NOD_COUNT 6
#define MAX_GRP_COUNT 7

//Parameter Types
#define INTEGER 		0 //
#define STRING 			1
#define CODE_INT 		2
#define CODE_STR 		3
#define REF_INT 		4
#define REF_STR 		5
#define INDEX_STR 		6 //
#define INDEX_INT 		7 //
#define INDEX_STR_INT 	8 //
#define INDEX_STR_REG 	9 //
#define NO_TYPE 		10//

//Parameter Access
#define READ_ONLY 	0
#define READ_WRITE 	1
#define PROTECTED 	2

//Parameter Values & Addresses
#define IS_CODE 	0
#define IS_ADDRESS 	0
#define PARAM_NONE 	0
#define NO_TABLE 	0
#define NO_FUNC 	0

#define MinMaxValues_size 24*4
const char* GetMinMaxValues(const char* command_name, const char* name, int* min, int* max);
const char* GetUnsignedMinMaxValues(const char* command_name, const char* name, unsigned int* min, unsigned int* max);

typedef struct
{
	const char Name[10];
	void* Address;			// address of value (depends on type, if 0 or 1)
	int* Value;				// value of code (depends on type, if 2)
	const char Type;		// Type, RW;
	const char RW;
	const short Size;
	ParamValue* CodeTable;	// ASCII Value Table
	int (*SetParameter)();
	ParameterSystem* systems;
	int SystemsCount;
}Parameter;

typedef struct
{
	const char Name[6];
	Parameter Parameters[12];
	int param_count;
}ParameterNode2;

typedef struct
{
	const char Name[5];
	ParameterNode2 ParameterNodes[8];
	int param_nod_count;
} ParameterNode1;

typedef struct
{
	ParameterNode1 Groups[GROUPS_COUNT];
	int grp_count;
}Root;

char group[MAX_GRP_LEN];
char node[MAX_PARAM_NOD_LEN];
char parameter[MAX_PARAMETER_LEN];

//ParameterNode1* CurrentGroup;
//ParameterNode2* CurrentNode;
//Parameter* CurrentParam;

typedef struct
{
	ParameterNode1* CurrentGroup;
	ParameterNode2* CurrentNode;
	Parameter* CurrentParam;
} GroupNodeParam;
GroupNodeParam groupNodeParam;

ParameterNode1* Group();
ParameterNode2* Node();
Parameter* Param();

extern const Root root;
int analys_param(char* path);
void init_code_params();
void save_code_params();

#endif /*PARAMETRS_H_*/



